import React from 'react'

class Input extends React.Component{
	constructor () {
		super()
		this.state = {
			iValue: ''
		}
		this.change = this.change.bind(this)
	}
	
	
	add = ()=>{
		this.props.click(this.state.iValue);
		this.setState({
			iValue: ''
		});
	}
	
	change = (event)=>{
		this.setState({
			iValue: event.target.value
		});
	}
	
	render(){
		const {length} = this.props;
		return (
			<div>
				<input value={this.state.iValue} onChange={this.change} />
				<button onClick={this.add}>add#{length}</button>
			</div>
		)
	}
}

export default Input